package com.youlu.campus.service.order;


import com.youlu.campus.base.order.vo.OrderRequest;

import com.youlu.campus.entity.OOrderInfo;
import com.youlu.campus.entity.OrderCommentInfo;
import com.youlu.campus.entity.OrderInfo;
import com.youlu.campus.entity.UserPO;
import com.youlu.campus.entity.VO.req.CreateCaOrderTagVO;
import com.youlu.campus.entity.VO.req.OrderPayCompensationVO;
import com.youlu.campus.entity.VO.req.OrderRefundOptVO;
import com.youlu.campus.entity.VO.res.MyOrderResponse;
import com.youlu.campus.entity.VO.res.PaperCaOrderResponse;
import com.youlu.campus.entity.domain.OrderUpdateRequest;
import org.springframework.data.domain.Page;

import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 订单管理接口
 */
public interface OrderService {

    /**
     * 纸质证书订单
     *
     * @param request
     * @return
     */
    Page<PaperCaOrderResponse> paperCaOrderList(OrderRequest request);

    Page<OrderInfo> getUserOrderPage(OrderRequest request);

    Map<String, Object> orderImport(byte[] inputStream, String fileName, String activityId, boolean sendMsg, String mode);


    Map<String, Object> reDoOrder(byte[] inputStream, String fileName, String activityId, String batchId);

    /**
     * 批量退款
     *
     * @param inputStream
     * @param fileName
     * @return
     */
    Map<String, Object> batchDoRefund(byte[] inputStream, String fileName, String optName);

    boolean addressUpdate(OrderUpdateRequest request);

    /**
     * 添加标签
     *
     * @param req
     * @return
     */
    List<String> createTags(CreateCaOrderTagVO req);

    /**
     * 删除标签
     *
     * @param req
     * @return
     */
    List<String> deleteTags(CreateCaOrderTagVO req);

    /**
     * 发货
     *
     * @param req
     * @return
     */
    boolean shipping(OrderInfo req);

    /**
     * 获取备注
     *
     * @param req
     * @return
     */
    List<OrderCommentInfo> getComments(OrderCommentInfo req);

    /**
     * 创建备注
     *
     * @param req
     * @return
     */
    boolean createComment(OrderCommentInfo req);

    /**
     * 获取详情
     *
     * @param id
     * @return
     */
    OrderInfo findOne(String id);

    /**
     * 订单导出
     *
     * @param req
     * @param response
     * @return
     */
    String export(OrderRequest req, HttpServletResponse response);

    /**
     * 退款审批
     *
     * @param req
     * @return
     */
    boolean doRefund(OrderRefundOptVO req);
    /**
     * 批量退款
     * @param
     * @return
     */
    boolean batchDoRefund(List<OrderRefundOptVO> reqs);

    /**
     * 退款预操作
     *
     * @param req
     * @return
     */
    boolean preRefund(OrderRefundOptVO req);

    boolean doRefundPassVerify(OrderRefundOptVO req, OrderInfo orderInfo, List<OOrderInfo> subOrders);

    /**
     * 支付成功后定时执行订单已支付变为定制中
     *
     * @param hour
     */
    void doOrderStatusJob(Integer hour);

    /**
     * 设置订单是否可退款
     *
     * @param orderInfo
     */
    void setRefundAndModify(OrderInfo orderInfo);

    /**
     * 开启退款功能
     *
     * @param orderNo
     * @return
     */
    HashMap<String, String> enableRefund(String orderNo);

    /**
     * 订单分析
     */
    void orderAnalysis();

    /**
     * 物流订单导出
     *
     * @param req
     * @param response
     * @return
     */
    String exportExpressOrder(OrderRequest req, HttpServletResponse response);

    /**
     * 合单订单导出
     *
     * @param req
     * @return
     */
    String exportSingleOrder(OrderRequest req);


    OrderInfo findByOrderNo(String orderNo);

    boolean updateStatus();

    /**
     * 根据当前用户、活动ID 获取用户订单
     *
     * @param currentUser
     * @param activityId
     * @return
     */
    List<MyOrderResponse> findByUserAndActivityId(UserPO currentUser, String activityId);

    /**
     * 退款订单导出
     *
     * @param req
     * @param response
     * @return
     */
    String exportRefundOrder(OrderRequest req, HttpServletResponse response);

    /**
     * 获取用户是否购买订单
     *
     * @param userId
     * @return
     */
    Boolean getBuyOrderByUserId(String userId);

    /**
     * 处理小程序订单自动退款
     *
     * @param platform
     */
    void doWechatMiniRefundOrder(String platform);

    /**
     * 同步证书编号
     *
     * @param start
     * @param end
     */
    List<OrderInfo> syncCaNumber(String batchId, Date start, Date end);

    void updateByMobileAndActivityId(String mobile, String toMobile, String activityId,
                                     String name, String universityId, String universityName,
                                     String userId);

     void doWechatH5RefundOrder(String platform);
}
